#pragma once

#include "vrdatacore_global.h"
#include "drawable.h"
#include <osgViewer\View>
#include <osgText\Text>
#include <osg\MatrixTransform>

namespace VrDataCore
{
	class VRDATACORE_EXPORT FrontAxisNode : public CoreBase::Drawable
	{
	public:
		FrontAxisNode(osgViewer::View* view);
		void update();
		osg::Node* getOSGNode();
		const osg::Node* getOSGNode() const;
		void createCrossLine(const osg::Vec3& base,float length,const osg::Vec4& colorx,const osg::Vec4& colory,const osg::Vec4& colorz);
	protected:
		~FrontAxisNode();
		void createCoordinateText(const osg::Vec3& xpos,const osg::Vec3& ypos,const osg::Vec3& zpos,
			const osg::Vec4& colorx,const osg::Vec4& colory,const osg::Vec4& colorz);
		osgViewer::View*							_withView;
		osg::ref_ptr<osg::Geode>					_realnode;
		osg::ref_ptr<osg::Geometry>					_lineX ;
		osg::ref_ptr<osg::Geometry>					_lineY ;
		osg::ref_ptr<osg::Geometry>					_lineZ ;
		osg::ref_ptr<osgText::Text>					_textgeoX ;
		osg::ref_ptr<osgText::Text>					_textgeoY ;
		osg::ref_ptr<osgText::Text>					_textgeoZ ;
		osg::ref_ptr<osg::MatrixTransform>			_transformNode;
		osg::Matrix									_baseTransMatrix;
	};
	class AxisUpdateCallback : public osg::NodeCallback
	{
	public:
		AxisUpdateCallback(FrontAxisNode* node ) {

			_axisNode = node ;
		}
		~AxisUpdateCallback() {} ;

		virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
		{
			if( _axisNode)
			{
				_axisNode->update() ;
			}
		}
	private:
		FrontAxisNode*				_axisNode ;
	} ;
}